package com.iwop.moto.service.impl;

import com.iwop.moto.model.SuperRecordModel;
import com.iwop.moto.service.BaseService;
import com.iwop.moto.service.OrderGoodsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liuwb 2016-07-27 15:33
 */
@Service
public class OrderGoodsServiceImpl extends BaseService implements OrderGoodsService {

    /**
     * 商品订单 - 主信息 - 新增
     */
    public void insertSelective(SuperRecordModel SRModel){
        getSqlSession().insert("MOrderGoodsMapper.insertSelective",SRModel);
    }

    /**
     * 商品订单 - 明细信息 - 新增
     */
    public void insertDetailSelective(SuperRecordModel SRModel){
        getSqlSession().insert("MOrderGoodsMapper.insertDetailSelective",SRModel);
    }

    /**
     * 商品订单 - 根据订单状态获取门店的订单
     */
    public List<SuperRecordModel> findOrderGoodsByStoreId(SuperRecordModel SRModel){
        return getSqlSession().selectList("MOrderGoodsMapper.findOrderGoodsByStoreId",SRModel);
    }

    /**
     * 商品订单 - 根据订单号获取主信息
     */
    public SuperRecordModel findByOrderNo(SuperRecordModel SRModel){
        return getSqlSession().selectOne("MOrderGoodsMapper.findByOrderNo",SRModel);
    }

    /**
     * 商品订单 - 根据订单号获取商品明细信息
     */
    public List<SuperRecordModel> findDetailByOrderNo(SuperRecordModel SRModel){
        return getSqlSession().selectList("MOrderGoodsMapper.findDetailByOrderNo",SRModel);
    }

    /**
     * 商品订单 - 根据订单号修改交易状态
     * orderNo :订单号
     * status :交易状态[0:未付款][1:已付款][2:同意退款][3:拒绝退款][4:退款中][5:交易关闭]
     * payTime : 状态更新时间
     */
    public void upOrderPayStatus(SuperRecordModel SRModel){
        getSqlSession().update("MOrderGoodsMapper.upOrderPayStatus",SRModel);
    }

    /**
     * 商品订单 - 根据订单号修改交易状态
     * orderNo :订单号
     * status  :订单状态[0:未发货][1:已发货][2:已收货][3:已退货][4:待评价][5:已评价]
     * orderStatusTime : 状态更新时间
     */
    public void upOrderStatus(SuperRecordModel SRModel){
        getSqlSession().update("MOrderGoodsMapper.upOrderStatus",SRModel);
    }

    @Override
    public void upOrderGoodsDelete(SuperRecordModel SRModel) {
        getSqlSession().update("MOrderGoodsMapper.upOrderGoodsDelete",SRModel);
    }
}
